﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wsitech.BLL;
using Wsitech.Model;

public partial class Backend_CompanyInfo : BackendPageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bindCompany();
        }
    }
    //绑定成员企业信息
    private void bindCompany()
    {
        repCompany.DataSource = CompanyInfoBLL.Instance.GetActiveList();
        repCompany.DataBind();
    }

    protected void repCompany_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        LinkButton lbtnEnable = (LinkButton)e.Item.FindControl("lbtnEnable");
        LinkButton lbtnDisable = (LinkButton)e.Item.FindControl("lbtnDisable");

        //显示和隐藏启用与禁用按钮
        CompanyInfo company = e.Item.DataItem as CompanyInfo;
        if (company != null)
        {
            if (company.JobUrlEnabled)
            {
                lbtnEnable.Visible = false;
            }
            else
            {
                lbtnDisable.Visible = false;
            }
        }
    }
    protected void repCompany_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        CompanyInfo company = CompanyInfoBLL.Instance.GetDetail(e.CommandArgument.ToString());
        if (company != null)
        {
            switch (e.CommandName)
            {
                case "Enable":
                    if (company.JobUrl != "")
                    {
                        company.JobUrlEnabled = true;
                    }
                    else
                    {
                        base.Alert("请先修改公司信息中的招聘首页！");
                        return;
                    }
                    break;
                case "Disable":
                    company.JobUrlEnabled = false;
                    break;
                default:
                    break;
            }
            CompanyInfoBLL.Instance.Update(company);
        }
        Response.Redirect(Request.Url.ToString());
    }
}